#pragma once
#include "IModule.h"
#include "ModuleManager_i.h"

typedef IModule *(*CREATORFUNC)();

#include <map>
#include <string>
std::map<std::string, CREATORFUNC> &GetClassDeposit();

DLL_EXPORT IModule * CreateModuleObject(const char *lpzClassName);
DLL_EXPORT bool GetClassNames(char **lpzClassName, size_t &nCount);

template<typename T>
class ObjectCreator
{
public:
	ObjectCreator(const char *lpzClassName)
	{
		GetClassDeposit().insert(std::make_pair(lpzClassName, CREATORFUNC(CreateObj)));
	}
	~ObjectCreator()
	{

	}
	static IModule* CreateObj()
	{
		return new T;
	}
};

class IModulesManager;

#define REGISTER_CLASS(ClassName, ExtraName) \
	static ObjectCreator<ClassName> ExtraName##_ObjCreator(#ExtraName);
#define DECLARE_CLASS \
	void Release(){		delete this;	}\
	void Init(IModulesManager *pModulesManager){m_pModulesManager = pModulesManager;}\
private:\
	IModulesManager *m_pModulesManager;\

